﻿
<link href="~/lib/layui/css/layui.css" rel="stylesheet" />   @* 一 ①样式 *@ @* ②layui js库 *@
<script src="~/js/js.cookie.js"></script>
<script src="~/js/moment.js"></script>
<script src="~/lib/layui/layui.js"></script>
<script src="~/lib/jquery/dist/jquery.js"></script>

<h2>
    日志分页列表
</h2>

<table class="layui-table">
    <tr>
         
        <td>Id</td>
        <td>时间</td>
        <td>级别</td>
        <td>日志内容</td>
    </tr>

   <tbody id="data"></tbody>
</table>
<div id="demo-laypage-all"></div>
<script>
    
    $(function () {
        showlog();
        Fenye();
    });
    var index = 1;
    var size = 10;
    var count = 0;

 
    function showlog() { 
        $.ajax({
            url: 'https://localhost:7061/api/Nlog/GetNlogModels?index=' + index + '&size=' + size ,
            type:'get',
            async: false,
            success: function (res) { 
                var tr = '';
                $(res.data).each(function (i,obj) { 
                    tr += `<tr> 
                                <td>${obj.id}</td>
                                <td>${obj.logger}</td>
                                <td>${obj.level}</td>
                                <td>${obj.massage}</td>
                             
                        </tr>`;
                });
                $("#data").html(tr);
                count = res.count;
            }
        });
    }

    function Fenye() {
        layui.use(function () {
            var laypage = layui.laypage;
            showlog();
            // 完整显示
            laypage.render({
                elem: 'demo-laypage-all', // 元素 id
                count: count, // 数据总数
                limit:size,
                limits:[3,5,6,7],
                layout: ['count', 'prev', 'page', 'next', 'limit', 'refresh', 'skip'], // 功能布局
                jump: function (obj) {
                    console.log(obj);
                    index = obj.curr;
                    size = obj.limit;
                    showlog()
                }
            });
        });
    }

</script>